package com.sc.nft.controller;


import com.sc.nft.annotation.UserLogin;
import com.sc.nft.controller.request.IdRequest;
import com.sc.nft.entity.dto.MallActivityShareDetailDTO;
import com.sc.nft.entity.dto.MallActivitySharePageDTO;
import com.sc.nft.pool.UserPool;
import com.sc.nft.service.MallActivityShareService;
import com.sc.nft.sup.PageRequest;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 分享购活动 前端控制器
 * </p>
 *
 * @author ligen
 * @since 2023-12-11
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/ipMall/activity/share")
@Api(tags = "分享购活动模块")
public class MallActivityShareController {

    public final MallActivityShareService mallActivityShareService;

    @ApiOperation(value = "分享购活动列表", notes = "分享购活动列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/page", produces = MediaType.APPLICATION_JSON_VALUE)
    @UserLogin
    public PageResult<MallActivitySharePageDTO> activityCouponsPage(@RequestBody PageRequest pageRequest) {
        return PageResult.success(mallActivityShareService.getMallActivitySharePageDTO(UserPool.getUser().getId(), pageRequest.getPageNo(), pageRequest.getPageSize()));
    }


    @ApiOperation(value = "分享购活动详情", notes = "分享购活动详情", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/details", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<MallActivityShareDetailDTO> details(@RequestBody IdRequest idRequest) {
        MallActivityShareDetailDTO mallActivityShareDetailDTO = mallActivityShareService.getMallActivityShareDetailDTO(idRequest.getId());
        return Result.success(mallActivityShareDetailDTO);
    }
}
